/*
 * Copyright (c) 2023 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef BUS_H
#define BUS_H

#include "internal/hasdef.h"
#include <mc/engine.h>
#include <memory>

namespace dev {

class chip_base; // 前向声明

class MC_API bus_base {
public:
    bus_base();
    virtual ~bus_base();

    void                       set_left_chip(std::shared_ptr<chip_base> left_chip);
    std::shared_ptr<chip_base> get_left_chip() const;

    // 添加虚函数声明
    virtual uint32_t read(ACCESS_DATA_S& input)  = 0;
    virtual uint32_t write(ACCESS_DATA_S& input) = 0;
    virtual uint8_t  get_id(); // 只声明，实现在cpp文件中
    virtual void     bus_lock()   = 0;
    virtual void     bus_unlock() = 0;
    virtual std::string get_object_name();

protected:
    // 前级器件指针 - 使用shared_ptr管理生命周期
    std::shared_ptr<chip_base> m_left_chip;
    std::string m_object_name = "null";
};

} // namespace dev

#endif // BUS_H
